package jmine.tec.utils.cripto.key.impl;

import java.security.KeyPair;

import jmine.tec.utils.cripto.key.GeradorChaveRSA;
import jmine.tec.utils.cripto.key.KeyPairHolder;


/**
 * Implementacao trivial de {@link KeyPairHolder} que gera um par novo de chaves a cada chamada a {@link #get()}. O tamanho default da
 * chave eh 1024
 * 
 * @author takeshi
 */
public class DynamicKeyPairHolder implements KeyPairHolder {

    private static final int DEFAULT_KEY_SIZE = 1024;

    private int size = DEFAULT_KEY_SIZE;

    /**
     * {@inheritDoc}
     */
    public KeyPair get() {
        return GeradorChaveRSA.geraParChavesRSA(size);
    }

    /**
     * @return the size
     */
    public int getSize() {
        return size;
    }

    /**
     * @param size the size to set
     */
    public void setSize(int size) {
        this.size = size;
    }

}
